<template>
    <div ref='form' class="app-form ">
                

<app-form-group v-show="detailsModel.group1.visible" layoutType="TABLE_24COL" titleStyle="" class='' uiActionGroup="detailsModel.group1.uiActionGroup" @groupuiactionclick="groupUIActionClick($event)" :caption="$t('expense.mobeditview_form_form.details.group1')" :isShowCaption="true" uiStyle="DEFAULT" :titleBarCloseMode="0" :isInfoGroupMode="false">
    
    
<app-form-item ref="namerules"  :checkValue="this.data.name" v-show="detailsModel.name.visible" name='name' :itemRules="this.rules.name" class='' :caption="$t('expense.mobeditview_form_form.details.name')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.name.error" :isEmptyCaption="false" labelPos="LEFT">
    <app-mob-input  class="app-form-item-input"  @change="($event)=>this.data.name = $event" :type="'text'"  :value="data.name" :disabled="detailsModel.name.disabled" ></app-mob-input>
</app-form-item>



<app-form-item ref="unit_amountrules"  :checkValue="this.data.unit_amount" v-show="detailsModel.unit_amount.visible" name='unit_amount' :itemRules="this.rules.unit_amount" class='' :caption="$t('expense.mobeditview_form_form.details.unit_amount')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.unit_amount.error" :isEmptyCaption="false" labelPos="LEFT">
    <app-mob-input  class="app-form-item-input"  @change="($event)=>this.data.unit_amount = $event" :type="'text'"  :value="data.unit_amount" :disabled="detailsModel.unit_amount.disabled" ></app-mob-input>
</app-form-item>



<app-form-item ref="quantityrules"  :checkValue="this.data.quantity" v-show="detailsModel.quantity.visible" name='quantity' :itemRules="this.rules.quantity" class='' :caption="$t('expense.mobeditview_form_form.details.quantity')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.quantity.error" :isEmptyCaption="false" labelPos="LEFT">
    <app-mob-input  class="app-form-item-input"  @change="($event)=>this.data.quantity = $event" :type="'text'"  :value="data.quantity" :disabled="detailsModel.quantity.disabled" ></app-mob-input>
</app-form-item>



<app-form-item ref="total_amountrules"  :checkValue="this.data.total_amount" v-show="detailsModel.total_amount.visible" name='total_amount' :itemRules="this.rules.total_amount" class='' :caption="$t('expense.mobeditview_form_form.details.total_amount')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.total_amount.error" :isEmptyCaption="false" labelPos="LEFT">
    <app-mob-input  class="app-form-item-input"  @change="($event)=>this.data.total_amount = $event" :type="'text'"  :value="data.total_amount" :disabled="detailsModel.total_amount.disabled" ></app-mob-input>
</app-form-item>



<app-form-item ref="expensedaterules"  :checkValue="this.data.expensedate" v-show="detailsModel.expensedate.visible" name='expensedate' :itemRules="this.rules.expensedate" class='' :caption="$t('expense.mobeditview_form_form.details.expensedate')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.expensedate.error" :isEmptyCaption="false" labelPos="LEFT">
    <app-mob-datetime-picker class="app-form-item-datetime" @change="($event)=>this.data.expensedate = $event"  :value="data.expensedate" :disabled="detailsModel.expensedate.disabled"></app-mob-datetime-picker>
</app-form-item>


    
</app-form-group>



<app-form-group v-show="detailsModel.grouppanel1.visible" layoutType="TABLE_24COL" titleStyle="" class='' uiActionGroup="detailsModel.grouppanel1.uiActionGroup" @groupuiactionclick="groupUIActionClick($event)" :caption="$t('expense.mobeditview_form_form.details.grouppanel1')" :isShowCaption="true" uiStyle="DEFAULT" :titleBarCloseMode="0" :isInfoGroupMode="false">
    
    
<app-form-item ref="actual_amountrules"  :checkValue="this.data.actual_amount" v-show="detailsModel.actual_amount.visible" name='actual_amount' :itemRules="this.rules.actual_amount" class='' :caption="$t('expense.mobeditview_form_form.details.actual_amount')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.actual_amount.error" :isEmptyCaption="false" labelPos="LEFT">
    <app-mob-input  class="app-form-item-input"  @change="($event)=>this.data.actual_amount = $event" :type="'text'"  :value="data.actual_amount" :disabled="detailsModel.actual_amount.disabled" ></app-mob-input>
</app-form-item>



<app-form-item ref="employee_idrules"  :checkValue="this.data.employee_id" v-show="detailsModel.employee_id.visible" name='employee_id' :itemRules="this.rules.employee_id" class='' :caption="$t('expense.mobeditview_form_form.details.employee_id')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.employee_id.error" :isEmptyCaption="false" labelPos="LEFT">
    <app-mob-input  class="app-form-item-input"  @change="($event)=>this.data.employee_id = $event" :type="'text'"  :value="data.employee_id" :disabled="detailsModel.employee_id.disabled" ></app-mob-input>
</app-form-item>



<app-form-item ref="orgnamerules"  :checkValue="this.data.orgname" v-show="detailsModel.orgname.visible" name='orgname' :itemRules="this.rules.orgname" class='' :caption="$t('expense.mobeditview_form_form.details.orgname')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.orgname.error" :isEmptyCaption="false" labelPos="LEFT">
    <app-mob-input  class="app-form-item-input"  @change="($event)=>this.data.orgname = $event" :type="'text'"  :value="data.orgname" :disabled="detailsModel.orgname.disabled" ></app-mob-input>
</app-form-item>



<app-form-item ref="payment_moderules"  :checkValue="this.data.payment_mode" v-show="detailsModel.payment_mode.visible" name='payment_mode' :itemRules="this.rules.payment_mode" class='' :caption="$t('expense.mobeditview_form_form.details.payment_mode')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.payment_mode.error" :isEmptyCaption="false" labelPos="LEFT">
    <app-mob-radio-list style="width: 100%;" :disabled="detailsModel.payment_mode.disabled" :value="data.payment_mode"  @change="($event)=>this.data.payment_mode = $event"   type="static" tag="UsrCodeList0824465552"></app-mob-radio-list>
</app-form-item>



<app-form-item ref="payment_wayrules"  :checkValue="this.data.payment_way" v-show="detailsModel.payment_way.visible" name='payment_way' :itemRules="this.rules.payment_way" class='' :caption="$t('expense.mobeditview_form_form.details.payment_way')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.payment_way.error" :isEmptyCaption="false" labelPos="LEFT">
    <app-mob-radio-list style="width: 100%;" :disabled="detailsModel.payment_way.disabled" :value="data.payment_way"  @change="($event)=>this.data.payment_way = $event"   type="static" tag="EXPENSE_PAYMENTWAY"></app-mob-radio-list>
</app-form-item>


    
</app-form-group>



<app-form-group v-show="detailsModel.grouppanel2.visible" layoutType="TABLE_24COL" titleStyle="" class='' uiActionGroup="detailsModel.grouppanel2.uiActionGroup" @groupuiactionclick="groupUIActionClick($event)" :caption="$t('expense.mobeditview_form_form.details.grouppanel2')" :isShowCaption="true" uiStyle="DEFAULT" :titleBarCloseMode="0" :isInfoGroupMode="false">
    
    
<app-form-item ref="descriptionrules"  :checkValue="this.data.description" v-show="detailsModel.description.visible" name='description' :itemRules="this.rules.description" class='' :caption="$t('expense.mobeditview_form_form.details.description')" uiStyle="DEFAULT" :labelWidth="0" :isShowCaption="false" :error="detailsModel.description.error" :isEmptyCaption="false" labelPos="NONE">
    <app-mob-textarea  class="app-form-item-textarea" @change="($event)=>this.data.description = $event"   :value="data.description" :disabled="detailsModel.description.disabled" ></app-mob-textarea>
</app-form-item>


    
</app-form-group>




    </div>
</template>

<script lang='ts'>
import { Vue, Component, Prop, Provide, Emit, Watch, Model } from 'vue-property-decorator';
import { CreateElement } from 'vue';
import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control';
import GlobalUiService from '@/global-ui-service/global-ui-service';
import ExpenseService from '@/app-core/service/expense/expense-service';
import MobEditView_FormService from '@/app-core/ctrl-service/expense/mob-edit-view-form-form-service';

import { FormButtonModel, FormPageModel, FormItemModel, FormDRUIPartModel, FormPartModel, FormGroupPanelModel, FormIFrameModel, FormRowItemModel, FormTabPageModel, FormTabPanelModel, FormUserControlModel } from '@/model/form-detail';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';


@Component({
    components: {
    }
})
export default class MobEditView_FormBase extends Vue implements ControlInterface {

    /**
     * 名称
     *
     * @type {string}
     * @memberof MobEditView_Form
     */
    @Prop() protected name?: string;

    /**
     * 视图通讯对象
     *
     * @type {Subject<ViewState>}
     * @memberof MobEditView_Form
     */
    @Prop() protected viewState!: Subject<ViewState>;

    /**
     * 应用上下文
     *
     * @type {*}
     * @memberof MobEditView_Form
     */
    @Prop({ default: {} }) protected context?: any;

    /**
     * 视图参数
     *
     * @type {*}
     * @memberof MobEditView_Form
     */
    @Prop({ default: {} }) protected viewparams?: any;

    /**
     * 视图状态事件
     *
     * @protected
     * @type {(Subscription | undefined)}
     * @memberof MobEditView_Form
     */
    protected viewStateEvent: Subscription | undefined;

    /**
     * 获取部件类型
     *
     * @returns {string}
     * @memberof MobEditView_Form
     */
    protected getControlType(): string {
        return 'FORM'
    }

    /**
     * 全局 ui 服务
     *
     * @private
     * @type {GlobalUiService}
     * @memberof MobEditView_Form
     */
    private globaluiservice: GlobalUiService = new GlobalUiService();

    /**
     * 建构部件服务对象
     *
     * @type {MobEditView_FormService}
     * @memberof MobEditView_Form
     */
    protected service: MobEditView_FormService = new MobEditView_FormService();

    /**
     * 实体服务对象
     *
     * @type {ExpenseService}
     * @memberof MobEditView_Form
     */
    protected appEntityService: ExpenseService = new ExpenseService();
    

    /**
     * 关闭视图
     *
     * @param {any[]} args
     * @memberof MobEditView_Form
     */
    protected closeView(args: any[]): void {
        let _this: any = this;
        _this.$emit('closeview', args);
    }


    
    /**
     * 获取多项数据
     *
     * @returns {any[]}
     * @memberof MobEditView_Form
     */
    public getDatas(): any[] {
        return [this.data];
    }

    /**
     * 获取单项树
     *
     * @returns {*}
     * @memberof MobEditView_Form
     */
    public getData(): any {
        return this.data;
    }

    /**
     * 是否默认保存
     *
     * @type {boolean}
     * @memberof MobEditView_Form
     */
    @Prop({ default: false }) protected autosave?: boolean;

    /**
     * 显示处理提示
     *
     * @type {boolean}
     * @memberof MobEditView_Form
     */
    @Prop({ default: true }) protected showBusyIndicator!: boolean;

    /**
     * 部件行为--submit
     *
     * @type {string}
     * @memberof MobEditView_Form
     */
    @Prop() protected WFSubmitAction!: string;
    
    /**
     * 部件行为--start
     *
     * @type {string}
     * @memberof MobEditView_Form
     */
    @Prop() protected WFStartAction!: string;
    
    /**
     * 部件行为--update
     *
     * @type {string}
     * @memberof MobEditView_Form
     */
    @Prop() protected updateAction!: string;
    
    /**
     * 部件行为--remove
     *
     * @type {string}
     * @memberof MobEditView_Form
     */
    @Prop() protected removeAction!: string;
    
    /**
     * 部件行为--loaddraft
     *
     * @type {string}
     * @memberof MobEditView_Form
     */
    @Prop() protected loaddraftAction!: string;
    
    /**
     * 部件行为--load
     *
     * @type {string}
     * @memberof MobEditView_Form
     */
    @Prop() protected loadAction!: string;
    
    /**
     * 部件行为--create
     *
     * @type {string}
     * @memberof MobEditView_Form
     */
    @Prop() protected createAction!: string;

    /**
     * 部件行为--create
     *
     * @type {string}
     * @memberof MobEditView_Form
     */
    @Prop() protected searchAction!: string;

    /**
     * 视图标识
     *
     * @type {string}
     * @memberof MobEditView_Form
     */
    @Prop() protected viewtag!: string;

    /**
     * 表单状态
     *
     * @type {Subject<any>}
     * @memberof MobEditView_Form
     */
    protected formState: Subject<any> = new Subject();

    /**
     * 忽略表单项值变化
     *
     * @type {boolean}
     * @memberof MobEditView_Form
     */
    protected ignorefieldvaluechange: boolean = false;

    /**
     * 数据变化
     *
     * @private
     * @type {Subject<any>}
     * @memberof MobEditView_Form
     */
    private dataChang: Subject<any> = new Subject();

    /**
     * 视图状态事件
     *
     * @private
     * @type {(Subscription | undefined)}
     * @memberof MobEditView_Form
     */
    private dataChangEvent: Subscription | undefined;

    /**
     * 原始数据
     *
     * @private
     * @type {*}
     * @memberof MobEditView_Form
     */
    private oldData: any = {};

    /**
     * 表单数据对象
     *
     * @type {*}
     * @memberof MobEditView_Form
     */
    protected data: any = {
        srfupdatedate: null,
        srforikey: null,
        srfkey: null,
        srfmajortext: null,
        srftempmode: null,
        srfuf: null,
        srfdeid: null,
        srfsourcekey: null,
        name: null,
        unit_amount: null,
        quantity: null,
        total_amount: null,
        expensedate: null,
        actual_amount: null,
        employee_id: null,
        orgname: null,
        payment_mode: null,
        payment_way: null,
        description: null,
        expenseid: null,
        expense: null,
    };

    /**
      * 当前执行的行为逻辑
      *
      * @type {string}
      * @memberof MobEditView_Form
      */
    protected currentAction: string = "";

    /**
      * 关系界面计数器
      *
      * @type {number}
      * @memberof MobEditView_Form
      */
    protected drcounter: number = 0;

    /**
      * 表单保存回调存储对象
      *
      * @type {any}
      * @memberof MobEditView_Form
      */
    protected saveState:any ;

    /**
     * 属性值规则
     *
     * @type {*}
     * @memberof MobEditView_Form
     */
    protected rules: any = {
        srfupdatedate: [
            { type: 'string', message: '更新时间 值必须为字符串类型', trigger: 'change' },
            { type: 'string', message: '更新时间 值必须为字符串类型', trigger: 'blur' },
            { required: false, type: 'string', message: '更新时间 值不能为空', trigger: 'change' },
            { required: false, type: 'string', message: '更新时间 值不能为空', trigger: 'blur' },
        ],
        srforikey: [
            { type: 'string', message: ' 值必须为字符串类型', trigger: 'change' },
            { type: 'string', message: ' 值必须为字符串类型', trigger: 'blur' },
            { required: false, type: 'string', message: ' 值不能为空', trigger: 'change' },
            { required: false, type: 'string', message: ' 值不能为空', trigger: 'blur' },
        ],
        srfkey: [
            { type: 'string', message: '报销明细标识 值必须为字符串类型', trigger: 'change' },
            { type: 'string', message: '报销明细标识 值必须为字符串类型', trigger: 'blur' },
            { required: false, type: 'string', message: '报销明细标识 值不能为空', trigger: 'change' },
            { required: false, type: 'string', message: '报销明细标识 值不能为空', trigger: 'blur' },
        ],
        srfmajortext: [
            { type: 'string', message: '报销明细名称 值必须为字符串类型', trigger: 'change' },
            { type: 'string', message: '报销明细名称 值必须为字符串类型', trigger: 'blur' },
            { required: false, type: 'string', message: '报销明细名称 值不能为空', trigger: 'change' },
            { required: false, type: 'string', message: '报销明细名称 值不能为空', trigger: 'blur' },
        ],
        srftempmode: [
            { type: 'string', message: ' 值必须为字符串类型', trigger: 'change' },
            { type: 'string', message: ' 值必须为字符串类型', trigger: 'blur' },
            { required: false, type: 'string', message: ' 值不能为空', trigger: 'change' },
            { required: false, type: 'string', message: ' 值不能为空', trigger: 'blur' },
        ],
        srfuf: [
            { type: 'string', message: ' 值必须为字符串类型', trigger: 'change' },
            { type: 'string', message: ' 值必须为字符串类型', trigger: 'blur' },
            { required: false, type: 'string', message: ' 值不能为空', trigger: 'change' },
            { required: false, type: 'string', message: ' 值不能为空', trigger: 'blur' },
        ],
        srfdeid: [
            { type: 'string', message: ' 值必须为字符串类型', trigger: 'change' },
            { type: 'string', message: ' 值必须为字符串类型', trigger: 'blur' },
            { required: false, type: 'string', message: ' 值不能为空', trigger: 'change' },
            { required: false, type: 'string', message: ' 值不能为空', trigger: 'blur' },
        ],
        srfsourcekey: [
            { type: 'string', message: ' 值必须为字符串类型', trigger: 'change' },
            { type: 'string', message: ' 值必须为字符串类型', trigger: 'blur' },
            { required: false, type: 'string', message: ' 值不能为空', trigger: 'change' },
            { required: false, type: 'string', message: ' 值不能为空', trigger: 'blur' },
        ],
        name: [
            { type: 'string', message: '费用说明 值必须为字符串类型', trigger: 'change' },
            { type: 'string', message: '费用说明 值必须为字符串类型', trigger: 'blur' },
            { required: false, type: 'string', message: '费用说明 值不能为空', trigger: 'change' },
            { required: false, type: 'string', message: '费用说明 值不能为空', trigger: 'blur' },
        ],
        unit_amount: [
            { type: 'number', message: '单价 值必须为数值类型', trigger: 'change' },
            { type: 'number', message: '单价 值必须为数值类型', trigger: 'blur' },
            { required: false, type: 'number', message: '单价 值不能为空', trigger: 'change' },
            { required: false, type: 'number', message: '单价 值不能为空', trigger: 'blur' },
        ],
        quantity: [
            { type: 'number', message: '数量 值必须为数值类型', trigger: 'change' },
            { type: 'number', message: '数量 值必须为数值类型', trigger: 'blur' },
            { required: false, type: 'number', message: '数量 值不能为空', trigger: 'change' },
            { required: false, type: 'number', message: '数量 值不能为空', trigger: 'blur' },
        ],
        total_amount: [
            { type: 'number', message: '总计 值必须为数值类型', trigger: 'change' },
            { type: 'number', message: '总计 值必须为数值类型', trigger: 'blur' },
            { required: false, type: 'number', message: '总计 值不能为空', trigger: 'change' },
            { required: false, type: 'number', message: '总计 值不能为空', trigger: 'blur' },
        ],
        expensedate: [
            { type: 'string', message: '费用日期 值必须为字符串类型', trigger: 'change' },
            { type: 'string', message: '费用日期 值必须为字符串类型', trigger: 'blur' },
            { required: false, type: 'string', message: '费用日期 值不能为空', trigger: 'change' },
            { required: false, type: 'string', message: '费用日期 值不能为空', trigger: 'blur' },
        ],
        actual_amount: [
            { type: 'number', message: '实际申请费用 值必须为数值类型', trigger: 'change' },
            { type: 'number', message: '实际申请费用 值必须为数值类型', trigger: 'blur' },
            { required: false, type: 'number', message: '实际申请费用 值不能为空', trigger: 'change' },
            { required: false, type: 'number', message: '实际申请费用 值不能为空', trigger: 'blur' },
        ],
        employee_id: [
            { type: 'string', message: '报销人 值必须为字符串类型', trigger: 'change' },
            { type: 'string', message: '报销人 值必须为字符串类型', trigger: 'blur' },
            { required: false, type: 'string', message: '报销人 值不能为空', trigger: 'change' },
            { required: false, type: 'string', message: '报销人 值不能为空', trigger: 'blur' },
        ],
        orgname: [
            { type: 'string', message: '所属公司 值必须为字符串类型', trigger: 'change' },
            { type: 'string', message: '所属公司 值必须为字符串类型', trigger: 'blur' },
            { required: false, type: 'string', message: '所属公司 值不能为空', trigger: 'change' },
            { required: false, type: 'string', message: '所属公司 值不能为空', trigger: 'blur' },
        ],
        payment_mode: [
            { type: 'string', message: '支付方向 值必须为字符串类型', trigger: 'change' },
            { type: 'string', message: '支付方向 值必须为字符串类型', trigger: 'blur' },
            { required: false, type: 'string', message: '支付方向 值不能为空', trigger: 'change' },
            { required: false, type: 'string', message: '支付方向 值不能为空', trigger: 'blur' },
        ],
        payment_way: [
            { type: 'string', message: '支付方式 值必须为字符串类型', trigger: 'change' },
            { type: 'string', message: '支付方式 值必须为字符串类型', trigger: 'blur' },
            { required: false, type: 'string', message: '支付方式 值不能为空', trigger: 'change' },
            { required: false, type: 'string', message: '支付方式 值不能为空', trigger: 'blur' },
        ],
        description: [
            { type: 'string', message: '备注... 值必须为字符串类型', trigger: 'change' },
            { type: 'string', message: '备注... 值必须为字符串类型', trigger: 'blur' },
            { required: false, type: 'string', message: '备注... 值不能为空', trigger: 'change' },
            { required: false, type: 'string', message: '备注... 值不能为空', trigger: 'blur' },
        ],
        expenseid: [
            { type: 'string', message: '报销明细标识 值必须为字符串类型', trigger: 'change' },
            { type: 'string', message: '报销明细标识 值必须为字符串类型', trigger: 'blur' },
            { required: false, type: 'string', message: '报销明细标识 值不能为空', trigger: 'change' },
            { required: false, type: 'string', message: '报销明细标识 值不能为空', trigger: 'blur' },
        ],
    }

    /**
     * 详情模型集合
     *
     * @type {*}
     * @memberof MobEditView_Form
     */
    protected detailsModel: any = {
        group1: new FormGroupPanelModel({ caption: '费用信息', detailType: 'GROUPPANEL', name: 'group1', visible: true, isShowCaption: true, form: this, uiActionGroup: { caption: '', langbase: 'expense.mobeditview_form_form', extractMode: 'ITEM', details: [] } })
, 
        grouppanel1: new FormGroupPanelModel({ caption: '基本信息', detailType: 'GROUPPANEL', name: 'grouppanel1', visible: true, isShowCaption: true, form: this, uiActionGroup: { caption: '', langbase: 'expense.mobeditview_form_form', extractMode: 'ITEM', details: [] } })
, 
        grouppanel2: new FormGroupPanelModel({ caption: '备注', detailType: 'GROUPPANEL', name: 'grouppanel2', visible: true, isShowCaption: true, form: this, uiActionGroup: { caption: '', langbase: 'expense.mobeditview_form_form', extractMode: 'ITEM', details: [] } })
, 
        formpage1: new FormPageModel({ caption: '基本信息', detailType: 'FORMPAGE', name: 'formpage1', visible: true, isShowCaption: true, form: this })
, 
        srfupdatedate: new FormItemModel({ caption: '更新时间', detailType: 'FORMITEM', name: 'srfupdatedate', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
, 
        srforikey: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srforikey', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
, 
        srfkey: new FormItemModel({ caption: '报销明细标识', detailType: 'FORMITEM', name: 'srfkey', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
, 
        srfmajortext: new FormItemModel({ caption: '报销明细名称', detailType: 'FORMITEM', name: 'srfmajortext', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
, 
        srftempmode: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srftempmode', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
, 
        srfuf: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srfuf', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
, 
        srfdeid: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srfdeid', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
, 
        srfsourcekey: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srfsourcekey', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
, 
        name: new FormItemModel({ caption: '费用说明', detailType: 'FORMITEM', name: 'name', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
, 
        unit_amount: new FormItemModel({ caption: '单价', detailType: 'FORMITEM', name: 'unit_amount', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
, 
        quantity: new FormItemModel({ caption: '数量', detailType: 'FORMITEM', name: 'quantity', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
, 
        total_amount: new FormItemModel({ caption: '总计', detailType: 'FORMITEM', name: 'total_amount', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
, 
        expensedate: new FormItemModel({ caption: '费用日期', detailType: 'FORMITEM', name: 'expensedate', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
, 
        actual_amount: new FormItemModel({ caption: '实际申请费用', detailType: 'FORMITEM', name: 'actual_amount', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
, 
        employee_id: new FormItemModel({ caption: '报销人', detailType: 'FORMITEM', name: 'employee_id', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
, 
        orgname: new FormItemModel({ caption: '所属公司', detailType: 'FORMITEM', name: 'orgname', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
, 
        payment_mode: new FormItemModel({ caption: '支付方向', detailType: 'FORMITEM', name: 'payment_mode', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
, 
        payment_way: new FormItemModel({ caption: '支付方式', detailType: 'FORMITEM', name: 'payment_way', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
, 
        description: new FormItemModel({ caption: '备注...', detailType: 'FORMITEM', name: 'description', visible: true, isShowCaption: false, form: this, disabled: false, enableCond: 3 })
, 
        expenseid: new FormItemModel({ caption: '报销明细标识', detailType: 'FORMITEM', name: 'expenseid', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
, 
    };

    /**
     * 监控表单属性 srfupdatedate 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof MobEditView_Form
     */
    @Watch('data.srfupdatedate')
    onSrfupdatedateChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'srfupdatedate', newVal: newVal, oldVal: oldVal });
    }

    /**
     * 监控表单属性 srforikey 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof MobEditView_Form
     */
    @Watch('data.srforikey')
    onSrforikeyChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'srforikey', newVal: newVal, oldVal: oldVal });
    }

    /**
     * 监控表单属性 srfkey 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof MobEditView_Form
     */
    @Watch('data.srfkey')
    onSrfkeyChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'srfkey', newVal: newVal, oldVal: oldVal });
    }

    /**
     * 监控表单属性 srfmajortext 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof MobEditView_Form
     */
    @Watch('data.srfmajortext')
    onSrfmajortextChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'srfmajortext', newVal: newVal, oldVal: oldVal });
    }

    /**
     * 监控表单属性 srftempmode 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof MobEditView_Form
     */
    @Watch('data.srftempmode')
    onSrftempmodeChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'srftempmode', newVal: newVal, oldVal: oldVal });
    }

    /**
     * 监控表单属性 srfuf 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof MobEditView_Form
     */
    @Watch('data.srfuf')
    onSrfufChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'srfuf', newVal: newVal, oldVal: oldVal });
    }

    /**
     * 监控表单属性 srfdeid 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof MobEditView_Form
     */
    @Watch('data.srfdeid')
    onSrfdeidChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'srfdeid', newVal: newVal, oldVal: oldVal });
    }

    /**
     * 监控表单属性 srfsourcekey 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof MobEditView_Form
     */
    @Watch('data.srfsourcekey')
    onSrfsourcekeyChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'srfsourcekey', newVal: newVal, oldVal: oldVal });
    }

    /**
     * 监控表单属性 name 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof MobEditView_Form
     */
    @Watch('data.name')
    onNameChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'name', newVal: newVal, oldVal: oldVal });
    }

    /**
     * 监控表单属性 unit_amount 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof MobEditView_Form
     */
    @Watch('data.unit_amount')
    onUnit_amountChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'unit_amount', newVal: newVal, oldVal: oldVal });
    }

    /**
     * 监控表单属性 quantity 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof MobEditView_Form
     */
    @Watch('data.quantity')
    onQuantityChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'quantity', newVal: newVal, oldVal: oldVal });
    }

    /**
     * 监控表单属性 total_amount 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof MobEditView_Form
     */
    @Watch('data.total_amount')
    onTotal_amountChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'total_amount', newVal: newVal, oldVal: oldVal });
    }

    /**
     * 监控表单属性 expensedate 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof MobEditView_Form
     */
    @Watch('data.expensedate')
    onExpensedateChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'expensedate', newVal: newVal, oldVal: oldVal });
    }

    /**
     * 监控表单属性 actual_amount 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof MobEditView_Form
     */
    @Watch('data.actual_amount')
    onActual_amountChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'actual_amount', newVal: newVal, oldVal: oldVal });
    }

    /**
     * 监控表单属性 employee_id 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof MobEditView_Form
     */
    @Watch('data.employee_id')
    onEmployee_idChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'employee_id', newVal: newVal, oldVal: oldVal });
    }

    /**
     * 监控表单属性 orgname 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof MobEditView_Form
     */
    @Watch('data.orgname')
    onOrgnameChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'orgname', newVal: newVal, oldVal: oldVal });
    }

    /**
     * 监控表单属性 payment_mode 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof MobEditView_Form
     */
    @Watch('data.payment_mode')
    onPayment_modeChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'payment_mode', newVal: newVal, oldVal: oldVal });
    }

    /**
     * 监控表单属性 payment_way 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof MobEditView_Form
     */
    @Watch('data.payment_way')
    onPayment_wayChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'payment_way', newVal: newVal, oldVal: oldVal });
    }

    /**
     * 监控表单属性 description 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof MobEditView_Form
     */
    @Watch('data.description')
    onDescriptionChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'description', newVal: newVal, oldVal: oldVal });
    }

    /**
     * 监控表单属性 expenseid 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof MobEditView_Form
     */
    @Watch('data.expenseid')
    onExpenseidChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'expenseid', newVal: newVal, oldVal: oldVal });
    }


    /**
     * 重置表单项值
     *
     * @private
     * @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
     * @memberof MobEditView_Form
     */
    private resetFormData({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void {
    }

    /**
      * 置空对象
      *
      * @param {any[]} args
      * @memberof EditForm
      */
    protected ResetData(_datas:any){
        if(Object.keys(_datas).length >0){
            Object.keys(_datas).forEach((name: string) => {
                if (this.data.hasOwnProperty(name)) {
                    this.data[name] = null;
                }
            });
        }
    }

    /**
     * 表单逻辑
     *
     * @private
     * @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
     * @memberof MobEditView_Form
     */
    private formLogic({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void {
                
























    }

    /**
     * 表单值变化
     *
     * @private
     * @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
     * @returns {void}
     * @memberof MobEditView_Form
     */
    private formDataChange({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void {
        if (this.ignorefieldvaluechange) {
            return;
        }
        this.resetFormData({ name: name, newVal: newVal, oldVal: oldVal });
        this.formLogic({ name: name, newVal: newVal, oldVal: oldVal });
        this.dataChang.next(JSON.stringify(this.data));
    }

    /**
     * 表单加载完成
     *
     * @private
     * @param {*} [data={}]
     * @param {string} [action]
     * @memberof MobEditView_Form
     */
    private onFormLoad(data: any = {},action:string): void {
        this.setFormEnableCond(data);
        this.fillForm(data,action);
        this.oldData = {};
        Object.assign(this.oldData, JSON.parse(JSON.stringify(this.data)));
        this.$store.commit('viewaction/setViewDataChange', { viewtag: this.viewtag, viewdatachange: false });
        this.formLogic({ name: '', newVal: null, oldVal: null });
    }

    /**
     * 值填充
     *
     * @param {*} [_datas={}]
     * @param {string} [action]
     * @memberof MobEditView_Form
     */
    protected fillForm(_datas: any = {},action:string): void {
        this.ignorefieldvaluechange = true;
        Object.keys(_datas).forEach((name: string) => {
            if (this.data.hasOwnProperty(name)) {
                this.data[name] = _datas[name];
            }
        });
        if(Object.is(action,'loadDraft')){
            this.createDefault();
        }
        this.$nextTick(function () {
            this.ignorefieldvaluechange = false;
        })
    }

    /**
     * 设置表单项是否启用
     *
     * @protected
     * @param {*} data
     * @memberof MobEditView_Form
     */
    protected setFormEnableCond(data: any): void {
        Object.values(this.detailsModel).forEach((detail: any) => {
            if (!Object.is(detail.detailType, 'FORMITEM')) {
                return;
            }
            const formItem: FormItemModel = detail;
            formItem.setEnableCond(data.srfuf);
        });
    }

    /**
     * 重置草稿表单状态
     *
     * @private
     * @memberof MobEditView_Form
     */
    private resetDraftFormStates(): void {
        const form: any = this.$refs.form;
        if (form) {
            // form.resetValidation();
        }
    }

    /**
     * 重置校验结果
     *
     * @memberof MobEditView_Form
     */
    protected resetValidates(): void {
        Object.values(this.detailsModel).forEach((detail: any) => {
            if (!Object.is(detail.detailType, 'FORMITEM')) {
                return;
            }
            const formItem: FormItemModel = detail;
            formItem.setError('');
        });
    }

    /**
     * 填充校验结果 （后台）
     *
     * @param {any[]} fieldErrors
     * @memberof MobEditView_Form
     */
    protected fillValidates(fieldErrors: any[]): void {
        fieldErrors.forEach((error: any) => {
            const formItem: FormItemModel = this.detailsModel[error.field];
            if (!formItem) {
                return;
            }
            this.$nextTick(() => {
                formItem.setError(error.message);
            });
        });
    }

    /**
     * 表单校验状态
     *
     * @returns {boolean} 
     * @memberof MobEditView_Form
     */
    protected formValidateStatus(): boolean {
        return this.cheackRules();
    }

    public cheackRules() :boolean{
        let refArr: Array<string> = ["srfupdatedaterules","srforikeyrules","srfkeyrules","srfmajortextrules","srftempmoderules","srfufrules","srfdeidrules","srfsourcekeyrules","namerules","unit_amountrules","quantityrules","total_amountrules","expensedaterules","actual_amountrules","employee_idrules","orgnamerules","payment_moderules","payment_wayrules","descriptionrules","expenseidrules",];
        let falg = true ; 
        refArr.forEach((item:any) => {
            if(this.$refs[item] && (this.$refs[item] as any).checkRule && !(this.$refs[item] as any).checkRule()){
                falg = false;
            }
        });
        return falg;
    }

    /**
     * 获取全部值
     *
     * @returns {*}
     * @memberof MobEditView_Form
     */
    protected getValues(): any {
        return this.data;
    }

    /**
     * 表单项值变更
     *
     * @param {{ name: string, value: any }} $event
     * @returns {void}
     * @memberof MobEditView_Form
     */
    protected onFormItemValueChange($event: { name: string, value: any }): void {
        if (!$event) {
            return;
        }
        if (!$event.name || Object.is($event.name, '') || !this.data.hasOwnProperty($event.name)) {
            return;
        }
        this.data[$event.name] = $event.value;
    }

    /**
     * 设置数据项值
     *
     * @param {string} name
     * @param {*} value
     * @returns {void}
     * @memberof MobEditView_Form
     */
    protected setDataItemValue(name: string, value: any): void {
        if (!name || Object.is(name, '') || !this.data.hasOwnProperty(name)) {
            return;
        }
        if (Object.is(this.data[name], value)) {
            return;
        }
        this.data[name] = value;
    }



    /**
     * 分组界面行为事件
     *
     * @param {*} $event
     * @memberof MobEditView_Form
     */
    protected groupUIActionClick($event: any): void {
        if (!$event) {
            return;
        }
        const item:any = $event.item;
    }

    /**
     * Vue声明周期(处理组件的输入属性)
     *
     * @memberof MobEditView_Form
     */
    protected created(): void {
        this.afterCreated();
    }

    /**
     * 执行created后的逻辑
     *
     *  @memberof MobEditView_Form
     */    
    protected afterCreated(){
        if (this.viewState) {
            this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => {
                if (!Object.is(tag, this.name)) {
                    return;
                }
                if (Object.is('autoload', action)) {
                    this.autoLoad(data);
                }
                if (Object.is('load', action)) {
                    this.load(data);
                }
                if (Object.is('loaddraft', action)) {
                    this.loadDraft(data);
                }
                if (Object.is('save', action)) {
                    this.save(data,data.showResultInfo);
                }
                if (Object.is('remove', action)) {
                    this.remove(data);
                }
                if (Object.is('saveandexit', action)) {
                    this.saveAndExit(data);
                }
                if (Object.is('saveandnew', action)) {
                    this.saveAndNew(data);
                }
                if (Object.is('removeandexit', action)) {
                    this.removeAndExit(data);
                }
                if (Object.is('refresh', action)) {
                    this.refresh(data);
                }
            });
        }
        this.dataChang
            .pipe(
                debounceTime(300),
                distinctUntilChanged()
            ).subscribe((data: any) => {
                if (this.autosave) {
                    this.autoSave();
                }
                const state = !Object.is(JSON.stringify(this.oldData), JSON.stringify(this.data)) ? true : false;
                this.$store.commit('viewaction/setViewDataChange', { viewtag: this.viewtag, viewdatachange: state });
            });
    }

    /**
     * vue 生命周期
     *
     * @memberof MobEditView_Form
     */
    protected destroyed() {
        this.afterDestroy();
    }

    /**
     * 执行destroyed后的逻辑
     *
     * @memberof MobEditView_Form
     */
    protected afterDestroy() {
        if (this.viewStateEvent) {
            this.viewStateEvent.unsubscribe();
        }
        if (this.dataChangEvent) {
            this.dataChangEvent.unsubscribe();
        }
    }

    /**
     * 拷贝内容
     *
     * @param {*} [arg={}]
     * @memberof @memberof MobEditView_Form
     */
    protected copy(arg: any = {}): void {
        this.loadDraft(arg);
    }

    /**
     * 部件刷新
     *
     * @param {any[]} args
     * @memberof MobEditView_Form
     */
    protected refresh(args: any[]): void {
        let arg: any = {};
        Object.assign(arg,args[0]);
        if (this.data.srfkey && !Object.is(this.data.srfkey, '')) {
            Object.assign(arg, { srfkey: this.data.srfkey });
            this.load(arg);
            return;
        }
        if (this.data.srfkeys && !Object.is(this.data.srfkeys, '')) {
            Object.assign(arg, { srfkey: this.data.srfkeys });
            this.load(arg);
            return;
        }
    }


    /**
     * 自动加载
     *
     * @param {*} [arg={}]
     * @returns {void}
     * @memberof MobEditView_Form
     */
    protected autoLoad(arg: any = {}): void {
        if (arg.srfkey && !Object.is(arg.srfkey, '')) {
            Object.assign(arg, { srfkey: arg.srfkey });
            this.load(arg);
            return;
        }
        if (arg.srfkeys && !Object.is(arg.srfkeys, '')) {
            Object.assign(arg, { srfkey: arg.srfkeys });
            this.load(arg);
            return;
        }
        this.loadDraft(arg);
    }

    /**
     * 加载
     *
     * @private
     * @param {*} [opt={}]
     * @returns {Promise<any>}
     * @memberof MobEditView_Form
     */
    private async load(opt: any = {}): Promise<any> {
        if (!this.loadAction) {
            this.$notice.error('ExpenseMobEditView视图表单loadAction参数未配置');
            return Promise.reject();
        }
        const arg: any = { ...opt };
        Object.assign(arg, this.viewparams);
        const response: any = await this.service.get(this.loadAction, { ...this.context }, arg, this.showBusyIndicator);
        if (response && response.status === 200) {
            const data = response.data;
            this.onFormLoad(data, 'load');
            this.$emit('load', data);
            this.$nextTick(() => {
                this.formState.next({ type: 'load', data: data });
            });
        } else if (response && response.status !== 401) {
            const { error: _data } = response;
            this.$notice.error(_data.message);
        }
        return response;
    }

    /**
     * 加载草稿
     *
     * @param {*} [opt={}]
     * @memberof MobEditView_Form
     */
    protected async loadDraft(opt: any = {}): Promise<any> {
        if (!this.loaddraftAction) {
            this.$notice.error('ExpenseMobEditView视图表单loaddraftAction参数未配置');
            return Promise.reject();
        }
        const arg: any = { ...opt } ;
        Object.assign(arg, this.viewparams);
        const response: any = await this.service.loadDraft(this.loaddraftAction, { ...this.context }, arg, this.showBusyIndicator);
        if (response && response.status === 200) {
            const data = response.data;
            if(data.expense){
                Object.assign(this.context, { expense: data.expense });
            }
            this.resetDraftFormStates();
            this.onFormLoad(data, 'loadDraft');
            this.$emit('load', data);
            this.$nextTick(() => {
                this.formState.next({ type: 'load', data: data });
            });
        } else if (response && response.status !== 401) {
            const { error: _data } = response;
            this.$notice.error(_data.message);
        }
        return response;
    }

    /**
     * 自动保存
     *
     * @protected
     * @param {*} [opt={}]
     * @returns {Promise<any>}
     * @memberof MobEditView_Form
     */
    protected async autoSave(opt: any = {}): Promise<any> {
        if (!this.formValidateStatus()) {
            return Promise.reject();
        }
        const arg: any = { ...opt };
        const data = this.getValues();
        Object.assign(arg, data);
        const action: any = Object.is(data.srfuf, '1') ? this.updateAction : this.createAction;
        if (!action) {
            let actionName: any = Object.is(data.srfuf, '1') ? "updateAction" : "createAction";
            this.$notice.error('ExpenseMobEditView视图表单' + actionName + '参数未配置');
            return Promise.reject();
        }
        Object.assign(arg, this.viewparams);
        const response: any = await this.service.add(action, { ...this.context }, arg, this.showBusyIndicator);
        if (response.status && response.status === 200) {
            const data = response.data;
            this.onFormLoad(data,'autoSave');
            this.$emit('save', data);
            this.$store.dispatch('viewaction/datasaved', { viewtag: this.viewtag });
            this.$nextTick(() => {
                this.formState.next({ type: 'save', data: data });
            });
        } else if (response.status && response.status !== 401) {
            const { error: _data } = response;
            if (Object.is(_data.status, 'BAD_REQUEST') && _data.parameters && _data.parameters.fieldErrors) {
                this.resetValidates();
                this.fillValidates(_data.parameters.fieldErrors)
            }
            this.$notice.error(_data.message);
        }
        return response;
    }

    /**
     * 保存
     *
     * @protected
     * @param {*} [opt={}]
     * @param {boolean} [showResultInfo]
     * @param {boolean} [isStateNext=true] 是否下发通知
     * @returns {Promise<any>}
     * @memberof MobEditView_Form
     */
    protected async save(opt: any = {}, showResultInfo?: boolean, isStateNext: boolean = true): Promise<any> {
        showResultInfo = showResultInfo === undefined ? true : false;
        opt.saveEmit = opt.saveEmit === undefined ? true : false;
        if (!this.formValidateStatus()) {
            this.$notice.error('值规则校验异常');
            return Promise.reject();
        }
        const arg: any = { ...opt };
        const data = this.getValues();
        Object.assign(arg, data);
        if (isStateNext) {
            this.drcounter = 0;
            if (this.drcounter !== 0) {
                this.formState.next({ type: 'beforesave', data: arg });//先通知关系界面保存
                this.saveState = Promise.resolve();
                return Promise.reject();
            }
        }
        const action: any = Object.is(data.srfuf, '1') ? this.updateAction : this.createAction;
        if (!action) {
            let actionName: any = Object.is(data.srfuf, '1') ? "updateAction" : "createAction";
            this.$notice.error('ExpenseMobEditView视图表单' + actionName + '参数未配置');
            return Promise.reject();
        }
        Object.assign(arg, this.viewparams);
        let response: any = null;
        if (Object.is(data.srfuf, '1')) {
            response = await this.service.update(action, { ...this.context }, arg, this.showBusyIndicator);
        } else {
            response = await this.service.add(action, { ...this.context }, arg, this.showBusyIndicator);
        }
        if (response && response.status === 200) {
            const data = response.data;
            this.onFormLoad(data, 'save');
            if(!opt.saveEmit){
                this.$emit('save', data);
            }                
            this.$store.dispatch('viewaction/datasaved', { viewtag: this.viewtag });
            this.$nextTick(() => {
                this.formState.next({ type: 'save', data: data });
            });
            if (showResultInfo) {
                this.$notice.success((data.srfmajortext ? data.srfmajortext : '') + '&nbsp;保存成功！');
            }
        } else if (response && response.status !== 401) {
            const { error: _data } = response;
            if (Object.is(_data.status, 'BAD_REQUEST') && _data.parameters && _data.parameters.fieldErrors) {
                this.resetValidates();
                this.fillValidates(_data.parameters.fieldErrors)
            }
            this.$notice.error(_data.message);
        }
        return response;
    }

    /**
     * 删除
     *
     * @private
     * @param {Array<any>} [opt=[]]
     * @param {boolean} [showResultInfo]
     * @returns {Promise<any>}
     * @memberof EditForm
     */
    private async remove(opt: Array<any> = [], showResultInfo?: boolean): Promise<any> {
        if (!this.removeAction) {
            this.$notice.error('ExpenseMobEditView视图表单removeAction参数未配置');
            return Promise.reject();
        }
        const arg: any = opt[0];
        const _this: any = this;
        Object.assign(arg, this.viewparams);
        const response: any = await this.service.delete(_this.removeAction, { ...this.context }, arg, showResultInfo);
        if (response && response.status === 200) {
            const data = response.data;
            this.$emit('remove', data);
            this.formState.next({ type: 'remove', data: data });
            this.data.ismodify = false;
            this.$notice.success((data.srfmajortext ? data.srfmajortext : '') + '&nbsp;删除成功！');
        } else if (response && response.status !== 401) {
            const { error: _data } = response;
            this.$notice.error(_data.message);
        }
        return response;
    }

    /**
     * 工作流启动
     *
     * @protected
     * @param {*} data
     * @returns {Promise<any>}
     * @memberof MobEditView_Form
     */
    protected async wfstart(data: any): Promise<any> {
        if (!this.WFStartAction) {
            this.$notice.error('ExpenseMobEditView视图表单WFStartAction参数未配置');
            return Promise.reject();
        }
        const _this: any = this;
        const arg: any = { ...data };
        Object.assign(arg, this.viewparams);
        let response: any = await this.service.wfstart(_this.WFStartAction, { ...this.context }, arg, this.showBusyIndicator);
        if (response && response.status === 200) {
            this.$notice.success('工作流启动成功');
        } else if (response && response.status !== 401) {
            this.$notice.error('工作流启动失败, ' + response.error.message);
        }
        return response;
    }

    /**
     * 工作流提交
     *
     * @protected
     * @param {*} data
     * @returns {Promise<any>}
     * @memberof MobEditView_Form
     */
    protected async wfsubmit(data: any): Promise<any> {
        if (!this.WFSubmitAction) {
            this.$notice.error('ExpenseMobEditView视图表单WFSubmitAction参数未配置');
            return Promise.reject();
        }
        const _this: any = this;
        const arg: any = { ...data };
        Object.assign(arg, this.viewparams);
        const response: any = this.service.wfsubmit(this.WFSubmitAction, { ...this.context }, arg, this.showBusyIndicator);
        if (response && response.status === 200) {
            this.$notice.success('工作流提交成功');
        } else if (response && response.status !== 401) {
            this.$notice.error('工作流提交失败, ' + response.error.message);
        }
        return response;
    }

    /**
     * 表单项更新
     *
     * @protected
     * @param {string} mode 界面行为名称
     * @param {*} [data={}] 请求数据
     * @param {string[]} updateDetails 更新项
     * @param {boolean} [showloading] 是否显示加载状态
     * @returns {Promise<any>}
     * @memberof MobEditView_Form
     */
    protected async updateFormItems(mode: string, data: any = {}, updateDetails: string[], showloading?: boolean): Promise<any> {
        if (!mode || (mode && Object.is(mode, ''))) {
            return Promise.reject();
        }
        const arg: any = { ...data };
        Object.assign(arg, this.viewparams);
        const response: any = await this.service.frontLogic(mode, { ...this.context }, arg, showloading);
        if (response && response.status === 200) {
            const data = response.data;
            const _data: any = {};
            updateDetails.forEach((name: string) => {
                if (!data.hasOwnProperty(name)) {
                    return;
                }
                Object.assign(_data, { [name]: data[name] });
            });
            this.setFormEnableCond(_data);
            this.fillForm(_data, 'updateFormItem');
            this.formLogic({ name: '', newVal: null, oldVal: null });
            this.dataChang.next(JSON.stringify(this.data));
            this.$nextTick(() => {
                this.formState.next({ type: 'updateformitem', ufimode: arg.srfufimode, data: _data });
            });
        } else if (response && response.status !== 401) {
            const { error: _data } = response;
            if (Object.is(_data.status, 'BAD_REQUEST') && _data.parameters && _data.parameters.fieldErrors) {
                this.resetValidates();
                this.fillValidates(_data.parameters.fieldErrors)
            }
            this.$notice.error(_data.message);
        }
        return response;
    }

    /**
     * 回车事件
     *
     * @param {*} $event
     * @memberof MobEditView_Form
     */
    protected onEnter($event: any): void {
    }

    /**
     * 保存并退出
     *
     * @param {any[]} args
     * @memberof MobEditView_Form
     */
    protected saveAndExit(data:any[]):Promise<any>{
        let _this = this;
        return new Promise((resolve: any, reject: any) =>{
            let arg: any = {};
            Object.assign(arg,data[0]);
            _this.currentAction = "saveAndExit";
            _this.save([arg]).then((res) =>{
                if(res){
                    _this.closeView(res.data);
                }
                resolve(res);
            }).catch((error) =>{
                reject(error);
            })
        })
    }

    /**
     * 保存并新建
     *
     * @param {any[]} args
     * @memberof MobEditView_Form
     */
    protected saveAndNew(data:any[]):Promise<any>{
        let _this = this;
        return new Promise((resolve: any, reject: any) =>{
            let arg: any = {};
            Object.assign(arg,data[0]);
            _this.currentAction = "saveAndNew";
            _this.save([arg]).then((res) =>{
                _this.ResetData(res);
                _this.loadDraft({});
            }).catch((error) =>{
                reject(error);
            })
        })
    }

    /**
     * 删除并退出
     *
     * @param {any[]} args
     * @memberof MobEditView_Form
     */
    protected removeAndExit(data:any[]):Promise<any>{
        let _this = this;
        return new Promise((resolve: any, reject: any) =>{
            let arg: any = {};
            Object.assign(arg,data[0]);
            _this.remove([arg]).then((res) =>{
                if(res){
                  _this.closeView(res.data);
                }
                resolve(res);
            }).catch((error) =>{
                reject(error);
            })
        })
    }

    /**
    * 关系界面数据保存完成
    *
    * @param {any} $event
    * @memberof MobEditView_Form
    */
    protected drdatasaved($event:any){
        let _this = this;
        this.drcounter--;
        if(this.drcounter > 0){
            return;
        }
        this.save({}, undefined, false).then((res) =>{
            this.saveState(res);
            if(Object.is(_this.currentAction, "saveAndNew")){
                _this.ResetData(res);
                _this.loadDraft({});
            }else if(Object.is(_this.currentAction, "saveAndExit")){
                if(res){
                    _this.closeView(res.data);
                }
            }
        });
    }

    /**
     * 新建默认值
     * @memberof MobEditView_Form
     */
    public createDefault(){                    
    }

    
}
</script>

<style lang='less'>
@import './mob-edit-view-form-form.less';
</style>